﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PMisuseAn.behaviour.model
{
    [Serializable()]
    public class State
    {
        string name_;
        int stateID_;
        string machineName_;
        string description_;
        string clusterName_;
        bool isMitigationPoint_;
        bool isMisusePoint_;
        bool isCallable_;
        int mitigationSeqRefIndex_;
        public List<Action> actions;

        private Action activeAction_;

        public MitigationReferences mitigationReferences;

        public State()
        {
            actions = new List<Action>();
        }

        public int stateID
        {
            get
            {
                return stateID_;
            }
            set
            {
                stateID_ = value;
            }
        }

        public int mitigationSeqRefIndex
        {
            get
            {
                return mitigationSeqRefIndex_;
            }
            set
            {
                mitigationSeqRefIndex_ = value;
            }
        }

        public void addAction(Action action)
        {
            bool exist = false;
            foreach (Action a in actions)
            {
                if(a.name.Equals(action.name))
                {
                    exist = true;
                }
            }
            if (exist == false)
            {
                actions.Add(action);
            }
        }

        public void removeAction(string actionName)
        {
            foreach (Action action in actions)
            {
                if (action.name.Equals(actionName))
                {
                    actions.Remove(action);
                    break;
                }
            }
        }

        public string clusterName
        {
            get
            {
                return clusterName_;
            }
            set
            {
                clusterName_ = value;
            }
        }

        public bool isMitigationPoint
        {
            get
            {
                return isMitigationPoint_;
            }
            set
            {
                isMitigationPoint_ = value;
            }
        }
        
        public bool isMisusePoint
        {
            get
            {
                return isMisusePoint_;
            }
            set
            {
                isMisusePoint_ = value;
            }
        }
        
        public string name
        {
            get
            {
                return name_;
            }
            set
            {
                name_ = value;
            }
        }

        public string machineName
        {
            get
            {
                return machineName_;
            }
            set
            {
                machineName_ = value;
            }
        }

        public string description
        {
            get
            {
                return description_;
            }
            set
            {
                description_ = value;
            }
        }

        public Action activeAction
        {
            get
            {
                return activeAction_;
            }
            set
            {
                activeAction_ = value;
            }
        }

        public bool isCallable
        {
            get
            {
                return isCallable_;
            }
            set
            {
                isCallable_ = value;
            }
        }
    }
}
